<?php
/*
*	Kleophatra - Open Source Content Management System
*	------------------------------------------------------------------------
*	Copyright (C) 2007-2010, Sergio Milardovich <smilardovich@yahoo.com.ar>
*	This program is Free Software.
*	Show posts
*
*	@package	Kleophatra
*	@subpackage	/modules/blog/widgets
*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
*	@author		Sergio Milardovich <smilardovich@yahoo.com.ar>
*	@link		http://www.kleophatra.org
*/
	$output=null;
	$ref = $_SESSION['widget_ref']['blog->read_feed'];
	$this->widget_form['blog->read_feed'] =  array(
   		"URL" => array("widget_read_feed_url","text"),
   		"Limit" => array("widget_read_feed_limit","text")
	);
	$limit = $this->get_core_value("widget_read_feed_limit", "name", $ref);
	$url = $this->get_core_value("widget_read_feed_url", "name", $ref);
	$wtitle = $this->get_core_value("widget_read_feed_title", "name", $ref);
	if(!isset($_SESSION['feed_container'.$ref])){
		$feed = file_get_contents($url);
		$this->apploadlib(KLEO_LIB_DIR."third_party/xml2array.lib.php", "xmltoarray", $xmltoarray);
		$array = $xmltoarray->xml2array($feed);
	
		$i=0;
		foreach($array['feed']['entry'] as $entry){
			$output .= '<div class="cont-new">
			      	<strong>'.$entry['title'].'</strong> - '.$entry['updated'].'
			    	</div>';
			$i++;
			if($i>=$limit)
			break;
		}
		$output .= '<div class="more">
		      	<div class="brown-button">
				<a href="'.$url.'" target="_blank" title="'.$wtitle.' Feed">'.L_MORE.'</a>
		      	</div>
		    	</div>';
		$_SESSION['feed_container'.$ref] = $output;
	} else {
		$output = $_SESSION['feed_container'.$ref];
	}
		echo $output;
?>
